package com.youyu.core.common.excel;

import java.util.ArrayList;
import java.util.List;

/**
 * <p>Author:  dengxj</p>
 * <p>Date: 2016/7/7 16:48</p>
 * <p>Description:excel数据行对象</p>
 * <p>Copyright: Copyright (c) 2016</p>
 * <p>Company: yihu.com</p>
 */
public class DataRow {
    //数据单元格数组
	private DataCell[] cell = null;
    //数据单元格list
	private List<DataCell> list = new ArrayList<DataCell>();

	public DataRow() {
	}

    /**
     * list 转换成 数组
     * @return
     */
	public DataCell[] getCell() {
		Object[] obj = list.toArray();
		int size = obj.length;
		cell = new DataCell[size];

		for (int i = 0; i < size; i++) {
			cell[i] = (DataCell) obj[i];
		}
		return cell;
	}
	
    /**
     * @param content 单元格内容
     * @param ctype 内容类型<br/>
     *      0: 小数（小数后2位）<br/>
     *      1: 文本<br/>
     *      5: 日期<br/>
     *      6: 日期时间<br/>
     *      7: 整数
     */
	public void addDataCell(String content, int ctype){
		 DataCell cell= new DataCell(); 
		 cell.setContent(content);
		 cell.setType(ctype);
		 list.add(cell);
	}
}